package com.well.rpc.model;

import lombok.Data;

import java.util.Objects;

@Data
public class ServerModel {

    private String serverName;

    private String ip;

    private Integer port;

    public static ServerModel getServerModer(RegisterModel model) {
        if (model == null) {
            return null;
        }
        ServerModel serverModel = new ServerModel();
        serverModel.setServerName(model.getServerName());
        serverModel.setPort(model.getServerPort());
        serverModel.setIp(model.getServerIp());
        return serverModel;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ServerModel that = (ServerModel) o;
        return Objects.equals(serverName, that.serverName) &&
                Objects.equals(ip, that.ip) &&
                Objects.equals(port, that.port);
    }

    @Override
    public int hashCode() {
        return Objects.hash(serverName, ip, port);
    }
}
